//
//  ChatConversationViewController.m
//  RZIM
//
//  Created by reyzhang on 2021/8/17.
//

#import "ChatConversationViewController.h"
#import "ChatInfoViewController.h"
#import "GroupInfoViewController.h"
#import "GroupSelectMemberViewController.h"
#import "RoomInfoViewController.h"
#import "VideoChatUserSelectViewController.h"

@interface ChatConversationViewController ()
@property (nonatomic,strong)UIButton *moreBtn;
@property (nonatomic,strong)NSMutableArray *userArray;

@end

@implementation ChatConversationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.userArray = [NSMutableArray array];
    UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithCustomView:self.moreBtn];
    self.navigationItem.rightBarButtonItem = right;

    
}

-(void)moreAction{
    
    if (self.conversationType == ConversationType_PRIVATE) {
        
        ChatInfoViewController *vc = [[ChatInfoViewController alloc]init];
        NSArray *array = [self.conversation valueForKey:@"userList"];
        YMUserInfo *info = array[0];
        vc.tid = info.userId;
        vc.targetId = self.targetId;
        [self.navigationController pushViewController:vc animated:YES];
        
    }else if (self.conversationType == ConversationType_GROUP){
        
        GroupInfoViewController *vc = [[GroupInfoViewController alloc]init];
        vc.groupId = self.targetId;
        [self.navigationController pushViewController:vc animated:YES];
        
    }else if (self.conversationType == ConversationType_CHATROOM){
        
        RoomInfoViewController *vc = [[RoomInfoViewController alloc]init];
        vc.roomId = self.targetId;
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}

-(void)back{
    
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)dealloc{
    
    [[NSNotificationCenter defaultCenter]removeObserver:self];
    
    
}
- (UIButton *)moreBtn {
    if (!_moreBtn) {
        _moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_moreBtn setImage:[UIImage imageNamed:@"Friend_More"] forState:UIControlStateNormal];
        _moreBtn.frame = CGRectMake(0, 0, 40, 40);
        [_moreBtn addTarget:self action:@selector(moreAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _moreBtn;
}

@end
